package com.sec.android.app.myfiles.facade.cmd;

import android.content.Context;

import com.sec.android.app.myfiles.log.Log;
import com.sec.android.app.myfiles.log.SamsungAnalyticsLog;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.module.abstraction.FileRecord.StorageType;
import com.sec.android.app.myfiles.navigation.NavigationInfo;
import com.sec.android.app.myfiles.navigation.NavigationInfo.NavigationMode;
import com.sec.android.app.myfiles.navigation.NavigationManager;
import com.sec.android.app.myfiles.util.UiUtils;

import org.puremvc.java.multicore.interfaces.INotification;
import org.puremvc.java.multicore.patterns.command.SimpleCommand;

public class GoPrivateFolderRootCmd extends SimpleCommand {

    private static final String TAG = GoPrivateFolderRootCmd.class.getSimpleName() + "-HYL";

    @Override
    public void execute(INotification notification) {
        Object[] params = (Object[]) notification.getBody();

        int processId = (Integer) params[0];
        NavigationInfo naviInfo = (NavigationInfo) params[1];
        Context context = (Context) params[2];
        NavigationMode mode = NavigationMode.Normal;
        if (naviInfo != null) {
            mode = naviInfo.getNavigationMode();
        }

        NavigationManager navigationManager = NavigationManager.getInstance(processId);

        NavigationInfo curInfo = navigationManager.getCurInfo();
        if (curInfo != null && curInfo.getStorageType() == StorageType.Home) {
            Log.e(this, "current storage type is home already");
            return;
        }

        //得到PrivateRecory的根目录
        FileRecord record = UiUtils.getPrivateRootRecord(context, curInfo);
        Log.i(TAG, "filerecord storageType is " + record.getStorageType());
        //FileRecord record = UiUtils.getHomeRecord(context, curInfo);

        naviInfo = NavigationInfo.getInstance(naviInfo, record);
		
        Log.i(TAG, "storageType is " + naviInfo.getStorageType());

		navigationManager.enter(naviInfo);
		
    }
}
